/**
 *
 * @param {*} selector 组件id
 * @param {*} ctx      当前webview
 * 参考wux-weapp
 */
const getCtx = (selector, ctx = getCurrentPages()[getCurrentPages().length - 1]) => {
  const componentCtx = ctx.selectComponent(selector);

  if (!componentCtx) {
    throw new Error('无法找到对应的组件，请按文档说明使用组件');
  }

  return componentCtx;
};
const $listLoading = (selector = '#listPullUpDown', ctx) => getCtx(selector, ctx).updateLoadStatus('LOADING');
const $listFinish = (selector = '#listPullUpDown', ctx) => getCtx(selector, ctx).updateLoadStatus('FINISH');
const $listLoaded = (selector = '#listPullUpDown', ctx) => getCtx(selector, ctx).updateLoadStatus('LOADED');
export { getCtx, $listLoading, $listFinish, $listLoaded };
